package com.youlu.campus.base.base;

import org.apache.commons.lang3.StringUtils;

/**
 * 互动动作行为枚举类
 * @author: YangJ
 * @date: 2020/12/14 15:57
 */
public enum InteractiveActionEnum {

    /**
     *
     */
    LIKE("like", "点赞"),

    SHARE("share", "分享"),

    COMMENT("comment", "评论"),

    HOT("hot", "热度"),

    JOIN("join", "参与"),

    CONTENT("content", "内容"),

    READ("read", "阅读"),
    ;

    private String code;
    private String desc;

    InteractiveActionEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 通过值获得名称
     */
    public static String getName(String code) {
        if (StringUtils.isNotBlank(code)) {
            for (InteractiveActionEnum typeEnum : InteractiveActionEnum.values()) {
                if (typeEnum.getCode().equals(code)) {
                    return typeEnum.getDesc();
                }
            }
        }
        return "";
    }
}
